﻿/**
 * 表单
 * @param	{JSON}	Data
 */
lhgdialog.form = function (data, callback) {
    var content = ['<form id="form" role="form">'];
    $.each(data, function (n, d) {
        if (n == 'id') return true;

        content.push('<div class="form-group">');
        content.push('<label for="input' + n + '" class="col-lg-3 control-label">' + n + '</label>');
        content.push('<div class="col-lg-9">');
        content.push('<input type="text" class="form-control" id="ipt' + n + '" value="' + d + '">');
        content.push('</div>');
        content.push('</div>');
    });
    content.push('</form>');

    return lhgdialog({
        title: '明细',
        id: 'form',
        fixed: true,
        lock: true,
        content: content.join(''),
        ok: function () {
            var $form = $('#form');
            $.each(data, function (n, d) {
                data[n] = $form.find('#ipt' + n).val();
            });
            callback && callback.call(this, data);
        },
        resize: false
    });
};